Skip to content

fix(interpreter): prevent byte range panic in ${#arr[idx]} with malformed input#1110

Merged
chaliy merged 1 commit intomainfrom
fix/issue-1090-byte-range-panic
Apr 6, 2026
Merged

fix(interpreter): prevent byte range panic in ${#arr[idx]} with malformed input#1110
chaliy merged 1 commit intomainfrom
fix/issue-1090-byte-range-panic

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 6, 2026

Summary

  • Fix panic in WordPart::Length handler when malformed input has ] before [
  • The handler searched for ] from the start of the string, but [ could appear later, causing name[bracket_pos + 1..index_end] to panic with reversed byte range
  • Fix: search for ] starting from the [ position

Changes

  • interpreter/mod.rs: search for ] relative to [ position in WordPart::Length handler
  • New byte_range_panic_tests.rs: 3 regression tests including decoded fuzz crash input

Test plan

  • cargo test --test byte_range_panic_tests — 3 new tests pass
  • cargo test --all-features -- --skip ssh_supabase — all pass
  • cargo clippy --all-targets --all-features -- -D warnings — clean

Closes #1090

…rmed input

The WordPart::Length handler searched for ']' from the start of the name
string, but '[' could appear after ']' in malformed input (e.g. fuzz
input with null bytes). This caused `name[bracket_pos + 1..index_end]`
to panic with "byte range starts at 43 but ends at 8" when
bracket_pos + 1 > index_end.

Fix by searching for ']' starting from the '[' position, ensuring the
closing bracket is always after the opening bracket.

Closes #1090
@chaliy chaliy merged commit de122ec into main Apr 6, 2026
18 of 27 checks passed
@chaliy chaliy deleted the fix/issue-1090-byte-range-panic branch April 6, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fuzz: arithmetic_fuzz panic — invalid byte range in interpreter

1 participant